#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,t,xlx,xly,ki,p,col;
long long a1[1005][1005],a2[1005][1005],ans2,ans,vals[1000005],valbf[1000005],a;
void dg(int x,int y,long long sum)
{
	if (x>n)
	{
		ans2=max(ans2,sum);return;
	}
	if (y>m)
	{
		dg(x+1,y,sum);return;
	}
	dg(x,y+1,sum);
	valbf[(x-1)*n+y+1]+=2*a2[x][y];
	valbf[(x*n+y)]+=2*a1[x][y];
}
int main()
{
	freopen("traffic.in","r",stdin);freopen("traffic.out","w",stdout);
	scanf("%d%d%d",&n,&m,&t);
	for (int i=1;i<=n-1;++i)
		for (int j=1;j<=m;++j)
			scanf("%lld",&a1[i][j]),vals[i*n+j]-=a1[i][j],vals[(i-1)*n+j]-=a1[i][j];
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m-1;++j)
			scanf("%lld",&a2[i][j]),vals[(i-1)*n+j]-=a2[i][j],vals[(i-1)*n+j+1]-=a2[i][j];
	while (t--)
	{
		for (int i=1;i<=n;++i)
			for (int j=1;j<=m;++j)
				valbf[(i-1)*n+j]=vals[(i-1)*n+j];
		ans=0;
		scanf("%d",&ki);
		for (int i=1;i<=ki;++i)
		{
			scanf("%lld%d%d",&a,&p,&col);
			if (p>m)
			{
				p-=m;
				if (p>n)
				{
					p-=n;
					if (p>m)
					{
						p-=m;xlx=n-p+1;xly=1;
					}
					else xlx=n,xly=m-p+1;
				}
				else xlx=p,xly=m;
			}
			else
				xlx=1,xly=p;
			if (col==0) valbf[(xlx-1)*n+m]-=a;
			else ans=ans+a,valbf[(xlx-1)*n+m]+=a;
		}
		ans2=0;
		dg(1,1,0);
		printf("%lld\n",ans-ans2);
	}
	return 0;
}
